//
//  AddDataFinishTipView.m
//  DailyRecord
//
//  Created by Gin on 2022/3/31.
//

#import "AddDataFinishTipView.h"
#import "UIImage+Resize.h"

@interface AddDataFinishTipView()

@property (nonatomic, strong) UIImageView *imgView;

@property (nonatomic, strong) UIButton *addBtn;

@end

@implementation AddDataFinishTipView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = kColorWithHex(0xffffff, 1);
    }
    return self;
}

- (void)initUI{
    [self addSubview:self.imgView];
    [self addSubview:self.addBtn];
}

- (void)setUpContraints{
    [self.addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self);
        make.size.mas_equalTo(CGSizeMake(150, kSmallButtonHeight));
    }];
    
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.size.mas_equalTo(CGSizeMake(32, 32));
        make.bottom.equalTo(self.addBtn.mas_top).offset(-kBottomSpace);
    }];
}

#pragma mark -- setter&&getter

- (UIImageView *)imgView{
    if (!_imgView) {
        _imgView = [UIImageView new];
        _imgView.image = [UIImage imageNamed:@"success"];
    }
    return _imgView;
}

- (UIButton *)addBtn{
    if (!_addBtn) {
        _addBtn = [UIButton new];
        [_addBtn setTitle:@"继续添加" forState:UIControlStateNormal];
        [_addBtn setBackgroundImage:[[UIImage imageNamed:@"btn_bg"] resizeWithCenter] forState:UIControlStateNormal];
        @weakify(self);
        [[_addBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            [self continueAddData];
        }];
    }
    return _addBtn;
}

@end
